package com.fatcat.easybuy.util;

import java.util.HashMap;

/**
 * @author 郝秦毅
 * @since 2025/9/10 11:36
 */
public class ResponseResult extends HashMap<String, Object> {

    private ResponseResult() {
    }

    public ResponseResult add(String key, Object value) {
        this.put(key, value);
        return this;
    }

    public static ResponseResult success() {
        return new ResponseResult().add("code", 200).add("msg", "success");
    }

    public static ResponseResult success(String msg) {
        return new ResponseResult().add("code", 200).add("msg", msg);
    }


    public static ResponseResult error() {
        return new ResponseResult().add("code", 500).add("msg", "failed");
    }

    public static ResponseResult error(String msg) {
        return new ResponseResult().add("code", 500).add("msg", msg);
    }

    public static ResponseResult error(Exception e) {
        return new ResponseResult().add("code", 500).add("error", e.getMessage());
    }

    public static ResponseResult error(String code, String msg) {
        return new ResponseResult().add("code", code).add("msg", msg);
    }
}
